{template 'common/header'}
{php load()->func('tpl')}
<div class="main">
    {if $op == 'post'}
    <ul class="nav nav-tabs">
        <li>
        	<a href="{php echo $this->createWebUrl('activity', array('op' => 'display'));}">活动管理</a>
        </li>
        <li {if intval($_GPC['id'])==0}class="active" {/if}>
        	<a href="{php echo $this->createWebUrl('activity', array('op' => 'post'));}">创建活动</a>
        </li>
        {if intval($_GPC['id'])!=0}
        <li class="active">
        	<a href="{php echo $this->createWebUrl('activity', array('op'=>'post','id'=>$item['id']));}">编辑活动</a>
        </li>
        {/if}
        <li {if $op == 'res'}class="active"{/if}>
        	<a href="{php echo $this->createWebUrl('activity', array('op' => 'res'));}">报名管理</a>
        </li>
    </ul>
    <form action="" class="form-horizontal form" method="post" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$item['id']}">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">活动信息</h3>
          </div>
          <div class="panel-body">
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">所属小区</label>
                <div class="col-sm-10">
                  {loop $regions $region}
                    <label class="checkbox-inline">
                      <input type="checkbox" id="" value="{$region['id']}" name='regionid[]' {if @in_array($region['id'], $regs)}checked='checked' {/if}> {$region['title']}
                    </label>
                  {/loop}
                </div>
            </div>
            <div class="form-group">
                <label for="title" class="col-sm-2 control-label">活动标题</label>
                <div class="col-xs-3">
                  <input type='text' name='title' id='title' class="form-control" value="{$item['title']}" placeholder="请输入活动标题"/>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">活动时间</label>
                <div class="col-sm-10">
                  {php echo tpl_form_field_daterange('birth', array('starttime' => $starttime,'endtime' => $endtime));}
                    <span class="help-block" style="display:block;clear:both;">活动报名的时间</span>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">报名截止</label>
                <div class="col-xs-2">
                  {php echo tpl_form_field_date('enddate',$item['enddate'],true);}
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">封面</label>
                <div class="col-xs-4">
                  {php echo tpl_form_field_image('picurl', $item['picurl'])}
                </div>
            </div>
            <div class="form-group">
                <label for="number" class="col-sm-2 control-label">每人最多报名数量</label>
                <div class="col-xs-4">
                   <input type='text' name='number' class="form-control" value="{$item['number']}" placeHolder="1" id='number'/>
                    <span class="help-block" style="display:block;clear:both;">如果允许一人报多个名额，请设置每人最多可报名数量。</span>
                </div>
            </div>
            <div class="form-group">
                <label for="number" class="col-sm-2 control-label">活动描述</label>
                <div class="col-sm-10">
                   <textarea  class="form-control" name="content" rows='8' id='content'>{$item['content']}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label for="ipt_status" class="col-sm-2 control-label">发布状态</label>
                <div class="col-sm-10">
                    <label class="checkbox-inline">
                       <input  name="status" id="ipt_status" type="checkbox" value='1' {if intval($item[ 'status'])==1}checked='checked' {/if} />推荐置顶
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label"></label>
                <div class="col-sm-10">
                   <button type="submit" class="btn btn-primary span3" name="submit" value="提交">提交</button>
                    <input type="hidden" name="token" value="{$_W['token']}" />
                </div>
            </div>
          </div>
        </div>
    </form>
    <script type="text/javascript">
        require(['jquery','util'], function($, util){
            $(function(){
                var editor = util.editor($('#content')[0]);
            });
        });
    </script>
    {elseif $op == 'display'}
    <ul class="nav nav-tabs">
        <li class="active"><a href="{php echo $this->createWebUrl('activity', array('op' => 'display'));}">活动管理</a>
        </li>
        <li><a href="{php echo $this->createWebUrl('activity', array('op' => 'post'));}">创建活动</a>
        </li>
        <li><a href="{php echo $this->createWebUrl('activity', array('op' => 'res'));}">报名管理</a>
        </li>
    </ul>
    <div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
            <form action="" method="post" class="form-horizontal" role="form">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 control-label">活动标题</label>
                    <div class="col-sm-8 col-md-8 col-lg-8 col-xs-12">
                        <input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}">
                    </div>
                </div>
                <div class="form-group">
                    <div class="pull-right col-xs-12 col-sm-2 col-md-2 col-lg-2">
                        <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div style="padding:15px;">
        <table class="table table-hover">
            <thead class="navbar-inner">
                <tr>
                    <th style="width:20%;">活动标题</th>
                    <th style="width:30%;">活动时间</th>
                    <th style="width:30%;">发布时间</th>
                    <th style="width:10%;">操作</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $item}
                <tr>
                    <td>{$item['title']}</td>
                    <td>{php echo date('Y-m-d', $item[starttime]);}-{php echo date('Y-m-d', $item[endtime]);}</td>
                    <td>{php echo date('Y-m-d H:i:s', $item[createtime]);}</td>
                    <td>
                        <span>
							<a href="{php echo $this->createWebUrl('activity',array('op'=>'post','id'=>$item['id']))}"><i class='glyphicon glyphicon-edit'></i>编辑</a>
							<a href="{php echo $this->createWebUrl('activity',array('op'=>'delete','id'=>$item['id']))}" onclick="return confirm('此操作不可恢复，确认吗？');"><i class='glyphicon glyphicon-remove-circle'></i>删除</a>
						</span>
                    </td>
                </tr>
                {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
    {elseif $op == 'res'}
    <ul class="nav nav-tabs">
        <li><a href="{php echo $this->createWebUrl('activity', array('op' => 'display'));}">活动管理</a>
        </li>
        <li><a href="{php echo $this->createWebUrl('activity', array('op' => 'post'));}">创建活动</a>
        </li>
        <li class="active"><a href="{php echo $this->createWebUrl('activity', array('op' => 'res'));}">报名管理</a>
        </li>
    </ul>
    <div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
            <form action="" method="post" class="form-horizontal" role="form">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 control-label">关键字</label>
                    <div class="col-sm-8 col-md-8 col-lg-8 col-xs-12">
                        <input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}">
                    </div>
                </div>
                <div class="form-group">
                    <div class="pull-right col-xs-12 col-sm-2 col-md-2 col-lg-2">
                        <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <form action="" method="post">
        <div style="padding:15px;">
            <table class="table table-hover">
                <thead class="navbar-inner">
                    <tr>
                        <th style="width:5%;">选择</th>
                        <th style="width:10%;">活动标题</th>
                        <th style="width:10%;">报名姓名</th>
                        <th style="width:10%;">性别</th>
                        <th style="width:10%;">报名电话</th>
                        <th style="width:10%;">报名数量</th>
                        <th style="width:30%;">报名时间</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $row $item}
                    <tr>
                        <td>
                            <input type="checkbox" name="select[]" value="{$item['id']}" />
                        </td>
                        <td>{$item['title']}</td>
                        <td>{$item['truename']}</td>
                        <td>{$item['sex']}</td>
                        <td>{$item['mobile']}</td>
                        <td>{$item['num']}</td>
                        <td>{php echo date('Y-m-d H:i:s', $item[createtime]);}</td>
                    </tr>
                    {/loop}
                </tbody>
            </table>
            {$pager}
            <table class="table">
                <tr>
                    {if !empty($row)}
                    <td style="width:40px;" class="row-first">
                        <input type="checkbox" onclick="selectall(this, 'select');" />
                    </td>
                    <td>
                        <input type="submit" name="delete" value="删除" class="btn btn-primary" />
                        <input type="hidden" name="token" value="{$_W['token']}" />
                    </td>
                    {/if}
                </tr>
            </table>
    </form>
    </div>
    {/if}
</div>
{template 'common/footer'}
